package com.zd.controller;

import com.zd.config.MinioConfig;
import com.zd.service.MinioService;
import io.minio.errors.*;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@RestController
public class FileController {

    @Autowired
    private MinioService minioService;

    @Resource
    private MinioConfig minioConfig;

    @PostMapping("/file/upload")
    public String upload(MultipartFile file) throws Exception {

        return minioService.uploadFile(minioConfig.getBucketName(),file);

    }

}
